package com.ebook.core.util;

import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.ebook.core.domain.ReadPosition;

public class ReadPositionUtil {
	
	private static Log logger = LogFactory.getLog(ReadPositionUtil.class);

	public static ReadPosition parseReadPosition(Map<String, Object> map) {
		try {
			Integer uid = (Integer)map.get("uid") == null ? 0 : (Integer)map.get("uid") ;
			Integer bookid = (Integer)map.get("bookid") == null ? 0 : (Integer)map.get("bookid") ;
			Integer readPositionid = (Integer)map.get("readPositionid") == null ? 0 : (Integer)map.get("readPositionid") ;
			String cfi = (String)map.get("cfi") == null ? "" : (String)map.get("cfi") ;
			Integer curr_chapter = (Integer)map.get("curr_chapter")  == null ? 0 : (Integer)map.get("curr_chapter") ;
			String update_time = (String)map.get("update_time")  == null ? "" : (String)map.get("update_time") ;
			return new ReadPosition(uid,bookid,readPositionid,cfi,curr_chapter,update_time);
		} catch (Exception e) {
			logger.error("创建  ReadPosition 对象失败" + e.getMessage());
			return null;
		}	
		
		
	}
}
